<?php

namespace Application\BankAccountBundle\Entity;

class BankAccount
{
    public function __construct($balance = 0)
    {
        $this->balance = (float) $balance;
    }

    public function getBalance()
    {
        return $this->balance;
    }

    public function credit($amount)
    {
        $this->balance += (float) abs($amount);
    }

    public function debit($amount)
    {
        $this->balance -= (float) abs($amount);
    }

    public function transfer($amount, BankAccount $account)
    {
        $this->debit($amount);
        $account->credit($amount);
    }
}